import {createStore} from 'vuex';

export default createStore ({
  state: {
    pageDataList: [],
  },
  mutations: {
    // 定义mutations，用于修改状态(同步)
    updateDataList (state, data) {
      state.pageDataList = data;
    },
  },
  actions: {
    // 定义actions，用于修改状态(异步)
    // 2秒后更新状态
    updateDataList (context, data) {
      context.commit ('updateDataList', data);
    },
  },
  getters: {
    // 定义一个getters
    pageDataList (state) {
      return state.pageDataList;
    },
  },
  modules: {},
});
